/*
 * Copyright (C) 2010 LianHaidong <lianhaidong@gmail.com>
 */

#ifndef _UTILS_STATIC_HASH_H
#define _UTILS_STATIC_HASH_H

#include "utils/list.h"

typedef int (*hash_func_t)(void *key);
typedef int (*hash_compare_t)(void *key1, void *key2);

struct static_hash_node {
	void *key;
	struct list_head entry;
};

struct static_hash_list {
	hash_func_t func;
	hash_compare_t compare;
	int index_max;
	struct list_head node[];
};

struct static_hash_list *static_hash_list_create(
		int index_max,
		hash_func_t func,
		hash_compare_t compare);

void static_hash_list_delete(struct static_hash_list *hl);

int static_hash_list_insert(struct static_hash_list *hl, 
                            struct static_hash_node *hn);

struct static_hash_node *static_hash_list_find(
		struct static_hash_list *hl, void *key);

int static_hash_node_del(struct static_hash_node *hn);

#endif	/* _UTILS_STATIC_HASH_H */
